home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.hitl.washington.edu
/
ftp.hitl.washington.edu.tar
/
ftp.hitl.washington.edu
/
pub
/
people
/
tsoper
/
My Sample Apps
/
OpenGl3Views
/
Form1.cs
< prev
next >
Wrap
Text File
|
2005-06-01
|
3KB
|
126 lines
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CsGL.OpenGL;
namespace OpenGl3Views
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
///
View view = new View();
private System.ComponentModel.Container components = null;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
Text = "OpenGL 3 Views Example";
view.SetBounds(10,10,100,100);
view.Dock = DockStyle.Left;
view.Dock = DockStyle.Top;
Controls.Add( view );
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "MainForm";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
class View : OpenGLControl
{
public override void glDraw()
{
GL.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); // Clear Screen And Depth Buffer
GL.glShadeModel( GL.GL_SMOOTH );
CsGL.OpenGL.GLUquadric q = GL.gluNewQuadric();
int radius;
radius = 1;
GL.gluQuadricDrawStyle(q,GL.GLU_LINE);
GL.glColor3f(1,0,0);
GL.gluSphere(q, radius, 20, 20);
GL.glFlush();
}
protected override void InitGLContext()
{
GL.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
GL.glEnable( GL.GL_DEPTH_TEST);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.glOrtho( -2,2, -2,2, 0,1000);
//GL.gluPerspective(90,1, 0.1,1000);
GL.glMatrixMode(GL.GL_MODELVIEW );
GL.glLoadIdentity();
GL.gluLookAt(0,0,3, 0,0,0, 0,1,0);
}
}